package 题目集.滑动窗口;

import java.util.Scanner;

/**
 * 滑动窗口
 * https://www.dotcpp.com/oj/contest6356_problem4.html
 */
public class 名称简写 {
    static int maxS = (int) (5 * 1e5) + 1;
    static int[] listA = new int[maxS], listB = new int[maxS];    //0位置标识a,b。1位置下标
    static int an, bn;
    static int n, k;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        k = sc.nextInt();
        String line = sc.next();
        n = line.length();
        char a = sc.next().charAt(0);
        char b = sc.next().charAt(0);
        for (int i = 0; i < n; i++) {
            if (line.charAt(i) == a) {
                listA[an++] = i;
            }
            if (line.charAt(i) == b) {
                listB[bn++] = i;
            }
        }
        long res = 0;
        for (int i = 0, j = 0; j < bn; j++) {
            while (i < an && listB[j]-listA[i]+1 >= k) {
                res+=bn-j;
                i++;
            }
        }
        System.out.println(res);
    }
}
